// Bean3.java：通过注解实现
package com.beantest;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class Bean3 {
    private String version;

    public Bean3() {
        System.out.println("bean3 实例化");
    }

    public void setVersion(String version) {
        System.out.println("bean3 属性赋值");
        this.version = version;
    }

    // 初始化方法：@PostConstruct注解
    @PostConstruct
    public void customInit() {
        System.out.println("bean3 初始化（@PostConstruct）");
    }

    // 销毁方法：@PreDestroy注解
    @PreDestroy
    public void customDestroy() {
        System.out.println("bean3 销毁（@PreDestroy）");
    }

    @Override
    public String toString() {
        return "Bean3当前状态: version=" + version;
    }
}
